package com.itheima.dao;

import com.itheima.domain.FilePojo;
import com.itheima.domain.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface FileDao {

    @Insert("insert into file  values(null,#{filename}, #{fileaddress}, #{uid})")
    public int save(FilePojo filePojo);

    @Update("update file set uid = #{uid}, filename = #{filename}, fileaddress = #{fileaddress}  where fid = #{fid}")
    public int update(FilePojo filePojo);

    @Delete("delete from file where fid = #{fid}")
    public int delete(Integer id);

    @Select("select * from file where fid = #{fid}")
    public FilePojo getById(Integer fid);

    @Select("select * from file")
    public List<FilePojo> getAll();

    @Select("select * from file WHERE filename LIKE CONCAT('%',#{filename},'%')")
    List<FilePojo> selectAllFiles(String filename);
}
